﻿<?php
header("Content-type:text/html;charset=utf-8");
if($_SERVER['REQUEST_METHOD'] != 'POST'){
	header('location:/');
}
include '../webadmin/inc/global.php';
class Request {
    public $get = array();
    public $post = array();
    public $cookie = array();
    public $files = array();
    public $server = array();
    public function __construct() {
            $this->get = $this->clean($_GET);
            $this->post = $this->clean($_POST);
            $this->request = $this->clean($_REQUEST);
            $this->cookie = $this->clean($_COOKIE);
            $this->files = $this->clean($_FILES);
            $this->server = $this->clean($_SERVER);
    }

    public function clean($data) {
            if (is_array($data)) {
                    foreach ($data as $key => $value) {
                            unset($data[$key]);
                            $data[$this->clean($key)] = $this->clean($value);
                    }
            } else {
                    $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
            }

            return $data;
    }
	public function escape($value) {
			$search = array("\\", "\0", "\n", "\r", "\x1a", "'", '"');
			$replace = array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"');
			return str_replace($search, $replace, $value);
	}
}

$request = new Request();
if(!isset($request->post['message'])){
	header('location:/');
}

$jobinfo = $request->post['message'];
$name = $request->escape($jobinfo['sen_message5']);
$email = $request->escape($jobinfo['sen_message6']);
$tit = $request->escape($jobinfo['sen_message7']);
$content = $request->escape($jobinfo['sen_message8']);
$time = time();
$ip = $ip = $_SERVER["REMOTE_ADDR"];


//引入发送邮件类
include 'smtp.php';
//require("smtp.php"); 
//使用163邮箱服务器
//163邮箱服务器端口 
$smtpserver = "smtp.163.com";
$smtpserverport = 25;
//你的163服务器邮箱账号
$smtpusermail = "zhongheweb@163.com";
//收件人邮箱
$smtpemailto = "1953891093@qq.com";
//你的邮箱账号(去掉@163.com)
$smtpuser = "zhongheweb";//SMTP服务器的用户帐号 
//你的邮箱密码
$smtppass = "zhongheweb2016"; //SMTP服务器的用户密码 
//邮件主题 
$mailsubject = "姓名：".$name."+邮箱：".$email."+主题：".$tit."+时间：".$time."+IP：".$ip;
//邮件内容 
$mailbody = $content;
//邮件格式（HTML/TXT）,TXT为文本邮件 
$mailtype = "TXT";
//这里面的一个true是表示使用身份验证,否则不使用身份验证. 
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
//是否显示发送的调试信息 
$smtp->debug = false;
//发送邮件
$mail = $smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);  
if($mail){
	echo "<script>alert('发送成功！');parent.location.href='/index.html';</script>";
}else{
	echo "<script>alert('发送失败！');parent.location.href='/index.html';</script>";
}
?> 